package ybl.baiducloud;

import java.io.InputStream;

import org.yaml.snakeyaml.Yaml;

import java.io.IOException;

public class ConfigSingleton {
    private static BaiduYunConf instance;

    private ConfigSingleton() {
    }

    public static BaiduYunConf getInstance() {
        if (instance == null) {
            Yaml yaml = new Yaml();

            try (InputStream inputStream = ConfigSingleton.class.getClassLoader()
                    .getResourceAsStream("baiduCloud.yml")) {
                instance = yaml.loadAs(inputStream, BaiduYunConf.class);
            } catch (IOException e) {
                e.printStackTrace();
                throw new RuntimeException("Failed to load configuration");
            }
        }
        return instance;
    }
}
